package org.example.xls.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.xls.common.Result;
import org.example.xls.pojo.dto.ConsultantAppointmentDTO;
import org.example.xls.pojo.vo.ConsultantVO;
import org.example.xls.service.ConsultantService;
import org.example.xls.tool.TheadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/consultant")
@Slf4j
public class ConsultantController {
    @Autowired
    private ConsultantService consultantService;

    /**
     * 查询 "查询列表"
     * @return
     */
    @GetMapping
    public Result<List<ConsultantVO>> getConsultantList() {
       return Result.success(consultantService.selectAll());
    }
    /**
     * 查询咨询师名单
     * @return
     */
    @GetMapping("/name")
    public Result<List<String>> getConsultantNameList() {
        return Result.success(consultantService.getConsultantNameList());
    }
    /**
     * 心理咨询-实现提交预约功能
     */
    @PostMapping("/appointment")
    public Result appointment(@RequestBody ConsultantAppointmentDTO consultantAppointmentDTO){
        consultantAppointmentDTO.setOpenId(TheadLocalUtil.getThreadLocal());
        log.info("咨询师预约,{}",consultantAppointmentDTO);
        consultantService.appointment(consultantAppointmentDTO);
        return Result.success();
    }
}